<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="common/common_head :: commonHeader('修改信息记录信息')"/>
    <link th:href="@{/css/plugins/datapicker/datepicker3.css}" rel="stylesheet">
</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">
    <form class="form-horizontal" method="post" id="inforecordFrom">
        <div class="row">
            <div class="form-group">
                <div class="col-sm-8" style="margin-left: 16px">
                    <input class="btn btn-primary" type="button" onclick="save()" value="保存">
                    <button class="btn btn-primary" type="button" onclick="Dialog.closeFrame(window.name)">取 消</button>
                </div>
            </div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>信息记录信息</h5>
                </div>
                <div class="ibox-content">
                    <div class="form-group">
                        <label class="col-xs-1 control-label"><span class="required-sign">*</span>信息记录编号：</label>
                        <div class="col-xs-3">
                            <input name="pkId" th:value="${inforecord.pkId}" readonly="readonly" type="hidden"/>
                            <input name="infoCode" th:value="${inforecord.infoCode}" readonly="readonly" type="text" class="form-control"/>
                        </div>
                        <label class="col-xs-1 control-label">物料号：</label>
                        <div class="col-xs-3">
                            <input name="materialCode" th:value="${inforecord.materialCode}" readonly="readonly"
                                   type="text" class="form-control"/>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-1 control-label">供应商编码</label>
                            <div class="col-xs-3">
                                <input name="srmCode" th:value="${inforecord.srmCode}" readonly="readonly"
                                       type="text" class="form-control"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-1 control-label">采购组</label>
                        <div class="col-xs-3">
                            <input name="purchaseGroup" th:value="${inforecord.purchaseGroup}" type="text" class="form-control"/>
                        </div>
                        <label class="col-xs-1 control-label">标准数量</label>
                        <div class="col-xs-3">
                            <input th:id="standardNum" name="standardNum" type="number" readonly th:value="${inforecord.standardNum}" class="form-control"/>
                        </div>
                        <label class="col-xs-1 control-label">周期</label>
                        <div class="col-xs-3">
                            <input th:id="cycle" name="cycle" type="number" readonly th:value="${inforecord.cycle}" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-1 control-label"><span class="required-sign">*</span>价格</label>
                        <div class="col-xs-3">
                            <input name="price" th:value="${inforecord.price}" type="number" required="required" class="form-control"/>
                        </div>
                        <label class="col-xs-1 control-label"><span class="required-sign">*</span>价格单位</label>
                        <div class="col-xs-3">
                            <input th:id="priceUnit" name="priceUnit" type="number" required="required" th:value="${inforecord.priceUnit}" class="form-control"/>
                        </div>
                        <label class="col-xs-1 control-label">采购订单单位</label>
                        <div class="col-xs-3" >
                            <input name="purchaseUnit" type="text" readonly th:value="${inforecord.purchaseUnit}" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-1 control-label"><span class="required-sign">*</span>有效起始日期</label>
                        <div class="col-xs-3">
                            <input th:id="startData" name="startData" type="text" required th:value="${#dates.format(inforecord.startData,'yyyy-MM-dd')}" class="form-control" autocomplete="off"/>
                        </div>
                        <label class="col-xs-1 control-label"><span class="required-sign">*</span>有效日期止</label>
                        <div class="col-xs-3">
                            <input th:id="priceEndData"  name="priceEndData" type="text" required th:value="${#dates.format(inforecord.priceEndData,'yyyy-MM-dd')}" class="form-control" autocomplete="off"/>
                        </div>
                        <label class="col-xs-1 control-label"><span class="required-sign">*</span>信息类别：</label>
                        <div class="col-xs-3">
                            <select id="classify" name="classify" class="form-control" th:data-val="${inforecord.classify}" sysDict="XXLB">
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<!-- Chosen -->
<script th:src="@{/static/js/plugins/chosen/chosen.jquery.js}"></script>
<script type="text/javascript">
    $(function () {
        initDictDataSel();//初始化所有字典数据
        // 初始化时间插件
        laydate.render({elem: '#startData'});
        laydate.render({elem: '#priceEndData'});
    });

    function save() {
        if ($("#inforecordFrom").valid()) {
            let priceUnit = $("#priceUnit").val();
            if (priceUnit <= 0) {
                Dialog.errorMsg("价格单位要大于0！");
                return false;
            }

            Page.ajaxPOST(ctxPath + "/inforecord/updatePriceDate", $('#inforecordFrom').serialize(), function (res) {
                Dialog.msg(res.msg);
                parent.refresh();
                Dialog.closeFrame(window.name);
            }, {"loadingMsg" : "正在往服务器提交数据……"});
        }
    }
</script>

</body>
</html>
